package ru.ifmo.mlarinsky.classificator.io;

import java.io.BufferedWriter;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.io.Writer;

public class XMLWriter {

    private XMLWriter() {
    }

    public static boolean write(String xml, String outputFilePath) {
        boolean result = false;
        Writer writer = null;
        try {
            File outputFile = new File(outputFilePath);
            writer = new BufferedWriter(new FileWriter(outputFile));

            writer.write(xml);

            result = true;
        } catch (IOException e) {
            e.printStackTrace();
            result = false;
        } finally {
            if (writer != null) {
                try {
                    writer.close();
                } catch (IOException e) {
                    e.printStackTrace();
                    result = false;
                }
            }
        }
        return result;
    }
}
